app.controller("subject",function($scope,$uibModal,$rootScope,del,$state,get,$stateParams,Upload ){
	var myDate = new Date();
	myDate.getFullYear();    //获取完整的年份(4位,1970-????)
	$scope.year=[]
	$scope.years=myDate.getFullYear();
	for(i=1;i<10;i++){
		$scope.year.push($scope.years-i)
	}
	$scope.year.unshift($scope.years)
	$scope.month=[]
	$scope.months=myDate.getMonth()+1;
	if($scope.months<10){
		$scope.months='0'+(myDate.getMonth()+1)
	}
	for(i=1;i<13;i++){
		if(i<10){
			$scope.month.push('0'+(i))
		}else{
			$scope.month.push(i)
		}
		
	}
	$scope.search=function(i){
		var param={
			year:$scope.years||null,
			month:$scope.months||null,
			
		}
		get.list("fee/subject",param).then(function(e){
			$scope.list=e
			$scope.list.forEach(function(o){
				money+=o.money
			})
			$scope.list.push({"name":"总计","money":money})
		})
		
   	
		
	
	}


	$scope.pageUp=function(){//跳转页码
       	if ($scope.tj.page>$scope.totalNum) {
       		$scope.tj.page=$scope.totalNum
       	} else if($scope.tj.page<1){
       	$scope.tj.page=null
       	}
       }//pageUp
   $scope.toPage=function(i){//点击跳转
       i=i||$scope.tj.page
       	$scope.search(i)
       	$scope.tj.current=$scope.tj.page;//页码调整
   }//toPage
   if($stateParams.page!=null){
			$scope.tj={
				page:$stateParams.page
			}
		 $scope.toPage($stateParams.page)
	}else{
			$scope.search();
	}
  
})
